import request from '/@/utils/request';
import { paramsSerializer } from '/@/utils/sort';

// 分类列表
export const cateList = (params?: object) => {
  return request({
    url: 'api/v1/admins/cate',
    method: 'get',
    params,
    paramsSerializer
  })
}

// 分类详情
export const cateDetail = (id: number) => {
  return request({
    url: `api/v1/admins/cate/${id}`,
    method: 'get',
  })
}

// 新增分类
export const addCate = (data: Object) => {
  return request({
    url: `api/v1/admins/cate`,
    method: 'post',
    data
  })
}

// 修改分类
export const updateCate = (data: Object) => {
  return request({
    url: `api/v1/admins/cate`,
    method: 'put',
    data
  })
}

// 删除分类
export const deleteCate = (id: number) => {
  return request({
    url: `api/v1/admins/cate/${id}`,
    method: 'delete'
  })
}

// 分类列表
export const treeList = (params?: object) => {
  return request({
    url: 'api/v1/admins/treeList',
    method: 'get',
    params,
    paramsSerializer
  })
}
